1. Field of the Invention
The invention relates to computer systems, and more particularly to the management of large objects (hereinafter xe2x80x9cLOBxe2x80x9d or xe2x80x9cLOBsxe2x80x9d) in a database system.
2. Background
LOB datatypes are used in a database system to store large blocks of structured or unstructured data, e.g., text, video, sound, or images. LOBs can be defined to contain any kind of data, including binary data, single-byte character set data, or multi-byte character set data. LOBs can be stored in memory structures defined within the database or external to the database in operating system files.
xe2x80x9cTemporary LOBsxe2x80x9d are LOB datatypes that are implemented for non-persistent usage. A temporary LOB is normally created with the expectation that it is to have a limited lifetime of existence, in which the temporary LOB and all of its associated resources are to be deleted or deallocated at the end of its lifetime.
Each temporary LOB is normally allocated a set of data pages or data blocks to store the LOB data. To track the memory/storage location of the temporary LOB, a system pointer or xe2x80x9clocatorxe2x80x9d is maintained that contains the address of one or more of the data pages for the temporary LOB. Index entries may also be maintained to index the contents or the data pages of the temporary LOB. Depending upon the specific purposes for which the temporary LOB is utilized, additional resources or data structures may also be allocated or associated with the temporary LOB.
When a temporary LOB is no longer needed or when it is at the end of its specified lifetime, the resources allocated to the temporary LOB should be deallocated or xe2x80x9cfreedxe2x80x9d to allow re-use of those resources for other purposes. To perform deallocation of the temporary LOBs, the database system must track the existence and location of all temporary LOBs on the system, as well as any resources associated or allocated to the temporary LOBs.
One approach that can be used is to require a user to explicitly track each temporary LOB that has been created by or for that user. The user is given information regarding the pointers or locators for each temporary LOB associated with that user. Under this approach, temporary LOBs are freed by having users make explicit calls to deallocate unneeded LOBs. In this manner, a user can determine exactly when and under what circumstances a temporary LOB will be freed.
One drawback to this approach is that it places a great burden upon the user to track and verify that unneeded temporary LOBs and their resources are deallocated. If the user fails to diligently monitor for temporary LOBs that have exceeded intended lifespans, then excess resources are being consumed on the system. Moreover, since the user is making explicit calls to free each individual temporary LOB, if multiple temporary LOBs having the same lifespan must be freed at the same time, the user is nonetheless forced to repetitively make the same explicit calls for each temporary LOB. In addition, significant resources may have to be expended, both by the user and system, to track each individual temporary LOB on the system.
According to an alternate approach, temporary LOBs are automatically terminated when the database shuts down or when a user session ends. The advantage of this approach is that it does not depend upon the user to perform the explicit task of removing unneeded temporary LOBs. However, this approach allows very little control over the lifespans of individual temporary LOBs. Moreover, temporary LOBs that are unneeded prior to the end of the default lifespan will unnecessarily consume system resources.
Therefore, there is a need for an improved method and mechanism for maintaining, tracking, and freeing temporary LOBs in a database system.
The invention is directed to a method and mechanism for duration-based management of temporary LOBs in a database system. According to an aspect of the invention, temporary LOBs are associated with a duration having a lifespan that corresponds to the lifespan of the temporary LOBs. When the duration ends, the temporary LOBs and any resources allocated to the temporary LOBs are automatically released. According to another aspect of the invention, multiple durations of varying, and possibly overlapping lifespans, can exist in the database system. According to yet another aspect of the invention, a tree of durations can be created having multiple ancestor and descendant durations.